package org.flashbrighton.as3bots.geom
{
	import org.flashbrighton.as3bots.utils.NumberUtils;
	
	// this class holds the geometric and math information for each Collidable
	public class Metrics
	{
		
		public var circle:Circle;
		public var vector:Vector2D;
		
		private var mSweepTest:Function;
		
		public function Metrics(x:Number = 0, y:Number = 0, ra:Number = 50, ro:Number = 0, dx:Number = 0, dy:Number = 0):void
		{
			circle = new Circle(x, y, ra, ro);
			vector = new Vector2D(dx, dy)
				
		}
		
		// the quadratic calculation to use when predictive collision testing
		public function get sweepTestMethod():Function
		{
			return mSweepTest;
		}
		
		public function set sweepTestMethod(param:Function):void
		{
			mSweepTest = param;
		}
		
		// this is called by the CollisionDetector, it executes the quadratic equation on its own metrics
		// and the metrics of the Collidable tested against
		public function getCollisionTime(m:Metrics):Number
		{
			return mSweepTest(this, m);
		}
		
		// adds a rotation value to the circle
		public function addRotation(param:Number):void
		{
			circle.rotation+=param;
			
		}
		
		// re calculates the vector from a velocity and the current rotation value
		public function applyVelocity(param:Number):void
		{
			var botRotation:Number = circle.rotation * Math.PI / 180;
			
			vector.x = param * Math.cos(botRotation); 
			vector.y = param * Math.sin(botRotation);			
			
		}
		
		// applies the vector to the x and y values of the circle
		// where t is the time between 0 and 1;
		public function applyVector(t:Number):void
		{	

			circle.x += (vector.x * t)
			circle.y += (vector.y * t)


		}

		
	
		
		
       
    
		
	}
}